package animal;

import java.util.ArrayList;

import field.Location;


public abstract class Animal {
	private int ageLimit093121121;
	private int breedableAge093121121;
	private int age093121121;
	private boolean isAlive093121121 = true;

	public Animal(int ageLimit093121121, int breedableAge093121121){
		this.ageLimit093121121 = ageLimit093121121;
		this.breedableAge093121121 = breedableAge093121121;
	}

	protected int getAge093121121(){
		return age093121121;
	}

	protected double getAgePercent093121121(){
		return (double)age093121121/ageLimit093121121;
	}

	public abstract Animal breed();

	public void grow(){
		age093121121++;
		if(age093121121 >= ageLimit093121121){
			die();
		}
	}

	public boolean isBreedable(){
		return age093121121 >= breedableAge093121121;
	}

	public void die(){
		isAlive093121121 = false;
	}

	public boolean isAlive(){
		return isAlive093121121;
	}

	public Location move(Location[] freeAdj){
		Location ret = null;
		if(freeAdj.length > 0 && Math.random() < 0.02){
			ret = freeAdj[(int)(Math.random() * freeAdj.length)];
		}
		return ret;
	}

	@Override
	public String toString() {
		return "" + age093121121 + ":" + (isAlive093121121 ? "live" : "dead");
	}

	public Animal feed(ArrayList<Animal> neighbour){
		return null;
	}

	protected void longerLife(int inc){
		ageLimit093121121 += inc;
	}
}
